#include "shareddir.h"
#include "globaldefinition.h"

using namespace std;

#define defLocalPath trUtf8("Не удалось определить путь к каталогу.")
#define defSharedName trUtf8("Не удалось определить сетевое имя каталога.")

SharedDir::SharedDir(const QString &localPath, const QString & sharedName, QObject *parent) :
    QObject(parent),
    m_localPath(localPath),
    m_shaedName(sharedName)
{
}

SharedDir::SharedDir(const string &localPath, const string &sharedName, QObject *parent)
{
    SharedDir(_q(localPath), _q(sharedName), parent);
}

const QString &SharedDir::localPath() const{
    try{
        m_shaedName;
    }catch(...){
        STANDART_ERROR_MASSAGE;
        return defLocalPath;
    }
}

void SharedDir::setLocalPath(const QString &localPath){
    try{
        if(localPath != this->localPath()){
            m_localPath = localPath;
            emit localPathChange();
        }
    }catch(...){
        STANDART_ERROR_MASSAGE;
    }
}

const QString &SharedDir::sharedName() const{
    try{
        return m_shaedName;
    }catch(...){
        STANDART_ERROR_MASSAGE;
        return defSharedName;
    }
}

void SharedDir::setSharedName(const QString &sharedName){
    try{
        if(sharedName != this->sharedName()){
            m_shaedName = sharedName;
            emit sharedNameChange();
        }
    }catch(...){
        STANDART_ERROR_MASSAGE;
    }
}
